<div class="title">
  <div class='content'>
    预订项目
  </div>
  <div class='tools'>    
    <%= link_to '厂家订做',
          new_order_made_order_item_order_url(@order),
          :remote => true,
          :method => :get,
          :id => :add_order_item
    %>
    <%= link_to '返回',
          order_items_order_url(@order_item.order),
          :remote => true,
          :method => :get
     %>
  </div>
</div>
<%= form_for @order_item, :as => :order_item,
     :url => create_spots_ordered_order_item_orders_url,
     :remote => true,
     :method => :post do |f|
 %>
<div class='info'>
  <table >
    <tr>
      <th>
        型号：
      </th>
      <td>
        <%= f.hidden_field :order_id %>
        <%= f.hidden_field :furniture_id %>
        <%= hidden_field_tag :furniture_style_id, params[:furniture_style_id] %>
        <%= autocomplete_field_tag :furniture_style_code,params[:furniture_style_code], autocomplete_furniture_style_code_furniture_styles_url, :id_element => '#furniture_style_id' %>
      </td>
    </tr>
    <tr>
      <th>
        材质：
      </th>
      <td>
        <%= hidden_field_tag :material_id, params[:material_id] %>
        <%= autocomplete_field_tag :material_code,params[:material_code], autocomplete_material_code_materials_url, :id_element => '#material_id' %>
        <%= link_to "查看库存",
              stored_furnitures_order_url(@order),
              :remote => true,
              :method => :get,
              :id => 'show_storages' %>

        <script type="text/javascript" charset="utf-8">
          $(document).ready(function(){
            $('#furniture_style_code').focus(function(){
              $(this).select();
            });
            $('#material_code').focus(function(){
              $(this).select();
            });
          });
        </script>
        <script type="text/javascript" charset="utf-8">
          $(document).ready(function(){
            $('#show_storages').bind('click',function(){
              $('.spots_order').show();
              $('#show_storages').attr('href', "<%= stored_furnitures_order_url(@order) %>?material_id=" + $('#material_id').val() + "&furniture_style_id=" + $('#furniture_style_id').val());
            });
          })
        </script>        
      </td>
    </tr>
    <tr id='stored_furnitures' class='hidden'>
      <th>库存：</th>
      <td></td>
    </tr>
    <tr>
      <th>
        备注：
      </th>
      <td >
        <%= f.text_area :remark, :rows => 5 %>
      </td>
    </tr>
    <tr>
      <td colspan='2' class='b'>
        <%= f.submit '现货预订', :class => 'bb spots_order' %>
        <%= link_to '返回',
              order_items_order_url(@order_item.order),
              :remote => true,
              :method => :get,
              :class => :bb
         %>
      </td>
    </tr>
  </table>
</div>
<% end %>